package dang.action.user;

import java.io.PrintWriter;

import dang.action.DangAction;
import dang.dao.DaoFactory;
import dang.dao.UserDao;
import dang.entity.User;

public class RegisterVerifyAction extends DangAction{
	private User user;
	public void verifyEmail() throws Exception{
		UserDao dao= DaoFactory.getUserDao();
		System.out.println(user);
		String rs = dao.verifyEmail(user.getEmail());
		response.setContentType("text/json;charset=utf-8");
		PrintWriter pw=response.getWriter();
		if("emailKeyong".equals(rs)){
			pw.print("true");
		}else{
			pw.print("false");
		}
		pw.close();
	}
	/**
	 * 验证码的验证
	 * @throws Exception
	 */
	public void verifyValidateCode() throws Exception{
		String code=(String) session.get("validateCode");
		response.setContentType("text/json;charset=utf-8");
		PrintWriter pw=response.getWriter();
		if(code.equalsIgnoreCase(request.getParameter("validateCode"))){
			pw.print("true");
		}else{
			pw.print("false");
		}
		pw.close();
		//return "verifyValidateCodeOk";
	}
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
}
